﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FisheryPlatform.Search.Core.Analysis
{
    /// <summary>			
    /// CharFilter
    /// description:	根据 WordSegment\filters\char.txt 中的配置进行字符替换
    /// create date:	2006-05
    /// author:			gwd
    /// </summary>
    public class CharFilter : Filter
    {
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="name"></param>
        /// <param name="fullPath"></param>
        public CharFilter(string name, string fullPath)
            : base(name, fullPath)
        {
        }

        /// <summary>
        /// Replace one character to anothing character or blank, based on filter config file.
        /// </summary>
        /// <param name="key">input character, only use key[0]</param>
        /// <returns>one character</returns>
        public override string Execute(string key)
        {
            if (this.Lookup(key[0].ToString())) key = this.GetItem(key)[0].ToString();

            return key[0].ToString();
        }

    }
}
